package c.h.a.j0;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.hardware.SensorManager;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.os.Environment;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.biometric.BiometricPrompt;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.m;
import androidx.recyclerview.widget.RecyclerView.z;
import c.h.a.f0.j;
import c.h.a.k0.a.a0;
import c.h.a.k0.a.b0;
import c.h.a.k0.a.c0;
import c.h.a.k0.a.d0;
import c.h.a.k0.a.f0;
import c.h.a.k0.a.g0;
import c.h.a.k0.a.h0;
import c.h.a.k0.a.i0;
import c.h.a.k0.a.j0.r;
import c.h.a.k0.a.y;
import c.h.a.m0.h;
import c.h.a.m0.i;
import c.h.a.m0.o;
import com.liuzh.deviceinfo.DeviceInfoApp;
import com.liuzh.deviceinfo.analyzer.StorageAnalyzeActivity;
import com.liuzh.deviceinfo.pro.ProActivity;
import com.liuzh.deviceinfo.tests.TestesActivity;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.Executors;

/* compiled from: TabTests */
public class z0 extends h0 implements OnSharedPreferenceChangeListener, c.h.a.f0.j.a {
    public BiometricPrompt W;
    public androidx.biometric.BiometricPrompt.e X;
    public List<e> Y = new ArrayList();
    public RecyclerView Z;
    public View b0;
    public f c0;

    /* compiled from: TabTests */
    public static class e {
        public String a;
        public int b;
        public String c;
        public int d;

        public e(String str, int i, String str2, int i2) {
            this.a = str;
            this.b = i;
            this.c = str2;
            this.d = i2;
        }
    }

    /* compiled from: TabTests */
    public class a extends c.h.b.a.a.b {
        public void b() {
            c.f.a.a.a.a.z("ad_tab_test");
        }

        public void c(String str) {
            z0 z0Var = z0.this;
            if (!z0Var.m0()) {
                ProActivity.G(z0Var.k());
                z0Var.u0();
            }
        }

        public void d(String str) {
            c.f.a.a.a.a.x("ad_tab_test", str);
        }

        public void e(View view) {
            if (!z0.this.m0()) {
                z0 z0Var = z0.this;
                z0Var.b0 = view;
                int s0 = z0Var.s0();
                if (s0 != -1) {
                    z0Var.Y.remove(s0);
                    z0Var.c0.e(s0);
                }
                z0Var.Y.add(2, new d());
                z0Var.c0.a.e(2, 1);
            }
        }
    }

    /* compiled from: TabTests */
    public class b extends androidx.recyclerview.widget.GridLayoutManager.b {
        public final /* synthetic */ GridLayoutManager c;

        public b(GridLayoutManager gridLayoutManager) {
            this.c = gridLayoutManager;
        }

        public int c(int i) {
            return z0.this.Y.get(i) instanceof d ? this.c.H : 1;
        }
    }

    /* compiled from: TabTests */
    public class c extends androidx.biometric.BiometricPrompt.b {
        public c(z0 z0Var) {
        }

        public void a(int i, CharSequence charSequence) {
            if (i == 13) {
                o.b.a(2);
            } else {
                o.b.a(0);
            }
        }

        public void b(androidx.biometric.BiometricPrompt.c cVar) {
            o.b.a(1);
        }
    }

    /* compiled from: TabTests */
    public static class d extends e {
    }

    /* compiled from: TabTests */
    public class f extends androidx.recyclerview.widget.RecyclerView.e<z> {
        public LayoutInflater c;

        /* compiled from: TabTests */
        public class a extends z {
            public a(f fVar, View view) {
                super(view);
            }
        }

        /* compiled from: TabTests */
        public class b extends z implements OnClickListener {
            public ImageView t;
            public TextView u;
            public ImageView v;
            public TextView w;

            public b(View view) {
                super(view);
                this.t = (ImageView) view.findViewById(2131297000);
                this.u = (TextView) view.findViewById(2131296753);
                this.v = (ImageView) view.findViewById(2131296628);
                this.w = (TextView) view.findViewById(2131297034);
                view.setOnClickListener(this);
            }

            public void onClick(View view) {
                e eVar = (e) z0.this.Y.get(e());
                if (eVar.a.equals("test_fingerprint")) {
                    z0 z0Var = z0.this;
                    z0Var.W.b(z0Var.X);
                    return;
                }
                Context context = view.getContext();
                z0 z0Var2 = z0.this;
                String str = eVar.a;
                str.hashCode();
                Object obj = -1;
                switch (str.hashCode()) {
                    case -2029703565:
                        if (str.equals("test_volume_up")) {
                            obj = null;
                            break;
                        }
                        break;
                    case -1639707159:
                        if (str.equals("test_ear_proximity")) {
                            obj = 1;
                            break;
                        }
                        break;
                    case -1180029278:
                        if (str.equals("test_wifi")) {
                            obj = 2;
                            break;
                        }
                        break;
                    case -630477190:
                        if (str.equals("test_volume_down")) {
                            obj = 3;
                            break;
                        }
                        break;
                    case 16720677:
                        if (str.equals("test_vibration")) {
                            obj = 4;
                            break;
                        }
                        break;
                    case 398850448:
                        if (str.equals("test_light_sensor")) {
                            obj = 5;
                            break;
                        }
                        break;
                    case 440048520:
                        if (str.equals("storage_analyze")) {
                            obj = 6;
                            break;
                        }
                        break;
                    case 835851173:
                        if (str.equals("screen_specific")) {
                            obj = 7;
                            break;
                        }
                        break;
                    case 930348703:
                        if (str.equals("test_loud_speaker")) {
                            obj = 8;
                            break;
                        }
                        break;
                    case 1872862451:
                        if (str.equals("test_flashlight")) {
                            obj = 9;
                            break;
                        }
                        break;
                    case 2012622825:
                        if (str.equals("test_ear_speaker")) {
                            obj = 10;
                            break;
                        }
                        break;
                    case 2067460929:
                        if (str.equals("test_bluetooth")) {
                            obj = 11;
                            break;
                        }
                        break;
                }
                switch (obj) {
                    case null:
                        TestesActivity.B(context, h0.class);
                        return;
                    case 1:
                        TestesActivity.B(context, c.h.a.k0.a.z.class);
                        return;
                    case 2:
                        TestesActivity.B(context, i0.class);
                        return;
                    case 3:
                        TestesActivity.B(context, g0.class);
                        return;
                    case 4:
                        TestesActivity.B(context, f0.class);
                        return;
                    case 5:
                        TestesActivity.B(context, c0.class);
                        return;
                    case 6:
                        c.h.a.v.a.b.c("test_ana_click", null);
                        str = "android.permission.WRITE_EXTERNAL_STORAGE";
                        if (c.h.a.e0.a.b(context, str, str)) {
                            StorageAnalyzeActivity.C(context, Environment.getExternalStorageDirectory().getPath());
                            return;
                        } else {
                            z0Var2.X(new String[]{"android.permission.READ_EXTERNAL_STORAGE", str}, 1);
                            return;
                        }
                    case 7:
                        TestesActivity.B(context, r.class);
                        return;
                    case 8:
                        TestesActivity.B(context, d0.class);
                        return;
                    case 9:
                        TestesActivity.B(context, b0.class);
                        return;
                    case 10:
                        TestesActivity.B(context, a0.class);
                        return;
                    case 11:
                        TestesActivity.B(context, y.class);
                        return;
                    default:
                        return;
                }
            }
        }

        public int a() {
            return z0.this.Y.size();
        }

        public int c(int i) {
            return z0.this.Y.get(i) instanceof d ? 1 : 0;
        }

        public void f(z zVar, int i) {
            e eVar = (e) z0.this.Y.get(i);
            if (eVar instanceof d) {
                ViewGroup viewGroup = (ViewGroup) zVar.a.findViewById(2131296331);
                if (viewGroup.getChildCount() == 0) {
                    View view = z0.this.b0;
                    if (view != null && view.getParent() == null) {
                        viewGroup.addView(z0.this.b0);
                        z0.this.b0.post(new d0(this));
                    }
                }
                return;
            }
            b bVar = (b) zVar;
            bVar.w.setVisibility(8);
            bVar.t.setVisibility(0);
            ImageView imageView;
            Context k;
            if (eVar.a.equals("screen_specific")) {
                bVar.t.setImageResource(2131231050);
                imageView = bVar.t;
                k = z0.this.k();
                Objects.requireNonNull(k);
                imageView.setColorFilter(b.i.c.a.b(k, 2131099707));
            } else if (eVar.a.equals("storage_analyze")) {
                bVar.t.setImageResource(2131230978);
                imageView = bVar.t;
                k = z0.this.k();
                Objects.requireNonNull(k);
                imageView.setColorFilter(b.i.c.a.b(k, 2131099707));
            } else {
                z0 z0Var = z0.this;
                ImageView imageView2 = bVar.t;
                int i2 = eVar.d;
                Objects.requireNonNull(z0Var);
                Context k2;
                if (i2 == 0) {
                    imageView2.setImageResource(2131231086);
                    k2 = z0Var.k();
                    Objects.requireNonNull(k2);
                    imageView2.setColorFilter(b.i.c.a.b(k2, 2131100022));
                } else if (i2 == 1) {
                    imageView2.setImageResource(2131231087);
                    k2 = z0Var.k();
                    Objects.requireNonNull(k2);
                    imageView2.setColorFilter(b.i.c.a.b(k2, 2131100025));
                } else if (i2 == 2) {
                    imageView2.setImageResource(2131231085);
                    k2 = z0Var.k();
                    Objects.requireNonNull(k2);
                    imageView2.setColorFilter(b.i.c.a.b(k2, 2131100021));
                }
            }
            bVar.u.setText(eVar.c);
            bVar.v.setImageResource(eVar.b);
        }

        public z g(ViewGroup viewGroup, int i) {
            if (this.c == null) {
                this.c = LayoutInflater.from(viewGroup.getContext());
            }
            if (i == 1) {
                return new a(this, this.c.inflate(2131492997, viewGroup, false));
            }
            return new b(this.c.inflate(2131492996, viewGroup, false));
        }
    }

    public void E(Bundle bundle) {
        super.E(bundle);
        o.b.a.registerOnSharedPreferenceChangeListener(this);
        j.d.h(this);
    }

    public View G(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        int i = VERSION.SDK_INT;
        if (this.Z == null) {
            RecyclerView recyclerView = (RecyclerView) layoutInflater.inflate(2131493060, viewGroup, false);
            this.Z = recyclerView;
            m layoutManager = recyclerView.getLayoutManager();
            if (layoutManager instanceof GridLayoutManager) {
                GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
                gridLayoutManager.M = new b(gridLayoutManager);
            }
            List list = this.Y;
            boolean p = h.p();
            o oVar = o.b;
            list.clear();
            String str = "storage_analyze";
            list.add(new e(str, 2131231061, x(2131690404), oVar.a.getInt(str, 2)));
            list.add(new e("screen_specific", 2131231052, x(2131689801), oVar.a.getInt("test_display", 2)));
            if (!p && Y().getPackageManager().hasSystemFeature("android.hardware.camera.flash")) {
                str = "test_flashlight";
                list.add(new e(str, 2131231033, x(2131689931), oVar.a.getInt(str, 2)));
            }
            str = "test_loud_speaker";
            list.add(new e(str, 2131231082, x(2131690056), oVar.a.getInt(str, 2)));
            if (!p) {
                str = "test_ear_speaker";
                list.add(new e(str, 2131231021, x(2131689815), oVar.a.getInt(str, 2)));
                str = "test_ear_proximity";
                list.add(new e(str, 2131231020, x(2131689813), oVar.a.getInt(str, 2)));
                SensorManager sensorManager = (SensorManager) Y().getSystemService("sensor");
                if (!(sensorManager == null || sensorManager.getDefaultSensor(2) == null)) {
                    str = "test_light_sensor";
                    list.add(new e(str, 2131231036, x(2131690045), oVar.a.getInt(str, 2)));
                }
            }
            str = "test_vibration";
            list.add(new e(str, 2131231091, x(2131690551), oVar.a.getInt(str, 2)));
            if (Y().getPackageManager().hasSystemFeature("android.hardware.wifi") && !h.b) {
                str = "test_wifi";
                list.add(new e(str, 2131231094, x(2131690569), oVar.a.getInt(str, 2)));
            }
            if (Y().getPackageManager().hasSystemFeature("android.hardware.bluetooth")) {
                str = "test_bluetooth";
                list.add(new e(str, 2131230983, x(2131689635), oVar.a.getInt(str, 2)));
            }
            if (!p && i >= 23 && Y().getPackageManager().hasSystemFeature("android.hardware.fingerprint")) {
                String str2 = "test_fingerprint";
                list.add(new e(str2, 2131231025, x(2131689925), oVar.a.getInt(str2, 2)));
            }
            if (!p) {
                String str3 = "test_volume_up";
                list.add(new e(str3, 2131231093, x(2131690558), oVar.a.getInt(str3, 2)));
                str = "test_volume_down";
                list.add(new e(str, 2131231092, x(2131690556), oVar.a.getInt(str, 2)));
            }
            f fVar = new f();
            this.c0 = fVar;
            this.Z.setAdapter(fVar);
            if (i >= 23) {
                this.W = new BiometricPrompt(Y(), Executors.newSingleThreadExecutor(), new c(this));
                Bundle bundle2 = new Bundle();
                String str4 = "title";
                bundle2.putCharSequence(str4, x(2131689925));
                bundle2.putCharSequence("subtitle", x(2131690183));
                bundle2.putCharSequence("description", x(2131690182));
                String str5 = "negative_text";
                bundle2.putCharSequence(str5, x(17039360));
                CharSequence charSequence = bundle2.getCharSequence(str4);
                CharSequence charSequence2 = bundle2.getCharSequence(str5);
                boolean z = bundle2.getBoolean("allow_device_credential");
                boolean z2 = bundle2.getBoolean("handling_device_credential_result");
                if (TextUtils.isEmpty(charSequence)) {
                    throw new IllegalArgumentException("Title must be set and non-empty");
                } else if (TextUtils.isEmpty(charSequence2) && !z) {
                    throw new IllegalArgumentException("Negative text must be set and non-empty");
                } else if (!TextUtils.isEmpty(charSequence2) && z) {
                    throw new IllegalArgumentException("Can't have both negative button behavior and device credential enabled");
                } else if (!z2 || z) {
                    this.X = new androidx.biometric.BiometricPrompt.e(bundle2);
                } else {
                    throw new IllegalArgumentException("Can't be handling device credential result without device credential enabled");
                }
            }
        }
        t0();
        return this.Z;
    }

    public void H() {
        this.E = true;
        o.b.a.unregisterOnSharedPreferenceChangeListener(this);
        j.d.h(this);
    }

    public void O(int i, String[] strArr, int[] iArr) {
        if (i != 1) {
            return;
        }
        if (c.h.a.e0.a.f(iArr)) {
            StorageAnalyzeActivity.C(Z(), Environment.getExternalStorageDirectory().getPath());
        } else if (!c.h.a.e0.a.d(this, "android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.READ_EXTERNAL_STORAGE")) {
            c.h.a.b0.o.r0(h(), 2131690076, 2131690406);
        }
    }

    public void P() {
        this.E = true;
        i iVar = i.a;
        iVar = i.a;
        if (i.b()) {
            u0();
        }
    }

    public void i(boolean z) {
        if (z) {
            u0();
        } else {
            t0();
        }
    }

    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String str) {
        int i = -1;
        for (int i2 = 0; i2 < this.Y.size(); i2++) {
            e eVar = (e) this.Y.get(i2);
            if (str.equals(eVar.a)) {
                o oVar = o.b;
                eVar.d = oVar.a.getInt(eVar.a, 2);
                i = i2;
            }
        }
        f fVar = this.c0;
        if (fVar != null && i != -1) {
            fVar.d(i);
        }
    }

    public String r0() {
        return DeviceInfoApp.c.getString(2131690451);
    }

    public final int s0() {
        for (int i = 0; i < this.Y.size(); i++) {
            if (this.Y.get(i) instanceof d) {
                return i;
            }
        }
        return -1;
    }

    public final void t0() {
        i iVar = i.a;
        iVar = i.a;
        if (!i.b() && !c.f.a.a.a.a.u()) {
            c.f.a.a.a.a.y("ad_tab_test");
            c.h.b.a.a.c.a(Z(), c.h.a.u.a.a, new a());
        }
    }

    public final void u0() {
        if (!m0()) {
            int s0 = s0();
            if (s0 != -1) {
                this.b0 = null;
                this.Y.remove(s0);
                this.c0.e(s0);
            }
        }
    }
}
